package com.serkol.driving.learning.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.serkol.driving.learning.entity.LoginLog;
import com.serkol.driving.learning.entity.SysRolePermission;
import com.serkol.driving.learning.mapper.SysRolePermissionMapper;
import com.serkol.driving.learning.service.SysRolePermissionService;
import com.serkol.constant.AuthConstant;
import com.serkol.driving.learning.handler.MyLambdaQueryWrapper;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author pingan
 * @description 针对表【sys_role_permission】的数据库操作Service实现
 * @createDate 2022-10-07 17:05:12
 */
@Service
public class SysRolePermissionServiceImpl extends ServiceImpl<SysRolePermissionMapper, SysRolePermission>
        implements SysRolePermissionService {

    @Override
    public List<Long> getMyRolePermissionsIds() {
        LoginLog loginLog = AuthConstant.getLoginLog();
        MyLambdaQueryWrapper<SysRolePermission> queryWrapper = new MyLambdaQueryWrapper<>();
        queryWrapper.select("MENU_ID");
        queryWrapper.eq(SysRolePermission::getRoleId, loginLog.getRoleId());

        List<Long> longs = (List<Long>) this.listObjs(queryWrapper, (o) -> {
            return Long.parseLong(String.valueOf(o));
        });
        return longs;
    }
}




